home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / gdv.cpp < prev    next >
C/C++ Source or Header  |  1996-02-26  |  5KB  |  206 lines

  1. /**********************************************************************
  2. *
  3. *       GDV.CPP
  4. *
  5. *
  6. *       Summary:    Play a GDV file
  7. *
  8. *       Author:   Kevin Dudley / Tony Crowther / Graeme Ing
  9. *
  10. *       Project:  Normality Inc   PC
  11. *
  12. *       Dated:    1527995 Wednesday 27-9-1995 15:59.
  13. *
  14. **********************************************************************/
  15.  
  16. #include <iostream.h>
  17. #include <stdlib.h>
  18. #include <stdio.h>
  19. #include <graph.h>
  20. #include <i86.h>
  21. #include <dos.h>
  22. #include <conio.h>
  23. #include <float.h>
  24. #include <time.h>
  25. #include <math.h>
  26. #include <string.h>
  27.  
  28.  
  29. #include "defines.h"
  30. #include "data.equ"
  31. #include "3deng.h"
  32. #include "menudisp.h"
  33. #include "menu.h"
  34. #include "video.h"
  35. #include "vesa.h"
  36. #include "unmangle.h"
  37. #include "actua.h"
  38. #include "memory.h"
  39. #include "gamedata.h"
  40. #include "menudata.h"
  41.  
  42. #include "config.h"
  43. #include "sos.h"
  44. #include "timer.h"
  45. #include "digi.h"
  46. #include "midi.h"
  47.  
  48. #include "playdam.h"                            // Structure Definitions for Digital Video
  49. #include "playcall.h"                        // Call Defininitions for Digital Video
  50. #include "animlink.h"
  51. #include "calldef.h"
  52. #include "memstruc.h"
  53. #include "rothlink.h"
  54. #include "mallocx.h"
  55.  
  56. #include "euro.equ"
  57. #include "euro_def.h"
  58. #include "euro_var.h"
  59. #include "euro_grf.h"
  60. #include "euro_dsk.h"
  61. #include "euro_fix.h"
  62. #include "euro_sel.h"
  63. #include "euro_inf.h"
  64. #include "euro_cnt.h"
  65. #include "euro_usr.h"
  66. #include "euro_net.h"
  67.  
  68. #define    GDV_MEM    512*1024
  69. #define GDV_ABORT                0x01
  70. #define GDV_LOOP                0x08
  71. #define DEFAULT_FADEIN        0
  72. #define DEFAULT_FADEOUT        0
  73. #define DEFAULT_DELAYEXIT    25
  74.  
  75. extern    "C"    volatile int count;
  76. extern    int    testVESA;
  77. extern    int     VESAmode(int *);
  78. extern    int    gdv_gran;
  79. extern     "C"     volatile char keys[256];
  80. extern         char    return_doskey;
  81. extern    BYTE         palette_buffer[];
  82. extern    BYTE         work_buffer[768];
  83.  
  84. extern    ModeInfoBlock *vmode_inf;
  85. char    out;
  86.  
  87.  
  88.  
  89. BYTE    presents[]={
  90.       0x3F,0x33,0x00,0x3F,0x33,0x0C,0x3F,0x33,0x19,0x3F,0x3F,0x26,
  91.             };
  92.  
  93. //---------------------------------------------------
  94. long int GDVCallbackRoutine(long int mode,void *header,void *data,short int frame)
  95. //---------------------------------------------------
  96. //
  97. // Callback generated by GDV player.
  98. // Test for abort GDV.
  99. //---------------------------------------------------
  100. {
  101.     out    =    NULL;
  102.  
  103.     if (mode == CBM_LookForAbort)
  104.     {
  105.         ReadMouseData(0);
  106.  
  107.             for (int i=1; i<255; i++)
  108.             {
  109.                  if (keys[i])
  110.                     out    =    1;
  111.             }
  112.         if (MouseBUTTONS & 3)
  113.             out    =    1;
  114.  
  115.         if (out!=NULL)
  116.             return(CBX_Abort);
  117.     }
  118.     return(CBX_Normal);
  119. }
  120.  
  121.  
  122. //---------------------------------------------------
  123. void PlayGDV()
  124. //---------------------------------------------------
  125. //
  126. // Play a GDV using an Anim structure
  127. //---------------------------------------------------
  128. {
  129.     char    file[128]; 
  130.     unsigned char *mem;
  131.     unsigned long int Error;
  132.     _PlayAnimBlock PlayBlock = { 0 };
  133.  
  134.     mem=(unsigned char *)mallocx(GDV_MEM);        // allocate mem for player
  135.  
  136.  
  137.     if (mem == 0)
  138.          return;
  139.     memset( mem, 0, GDV_MEM );
  140.  
  141.     strcpy    (file, EuroGDVfile);
  142.  
  143.     PlayBlock.FileName     =     &file[0];
  144.     PlayBlock.Flags        =     NULL;
  145.     PlayBlock.Screen    =     0x110;
  146.     PlayBlock.ScreenXSize    =     640;
  147.     PlayBlock.ScreenYSize    =     480;
  148.           PlayBlock.ScreenGran    =    0;   
  149.  
  150.           if (SoundCard==0)
  151.               PlayBlock.Flags|=    PAF_NoAudio;
  152.  
  153.         PlayBlock.CallBack = &GDVCallbackRoutine;
  154.           PlayBlock.DrvPath="DIGI\\";
  155.     PlayBlock.MemBlock=mem;
  156.     PlayBlock.MemBlockSize=GDV_MEM;
  157.     
  158.     if (SoundCard==0)
  159.         PlayBlock.Flags|=     PAF_NoAudio;
  160.     else
  161.         PlayBlock.DIGIHandle_SOS=DIGIDriverHandle;
  162.  
  163.     PlayBlock.DriveCap_SOS=&DIGICapabilities;
  164.     PlayBlock.SNDID=SoundCard;
  165.     PlayBlock.SNDPort=SoundPort;
  166.     PlayBlock.SNDIRQ=SoundIRQ;
  167.     PlayBlock.SNDDMA=SoundDMA;
  168.     PlayBlock.SNDPara=0;
  169.  
  170.  
  171.     if(!(Error=InitAnim(&PlayBlock)))
  172.     {
  173.         Error=StartAnim(&PlayBlock);
  174.         CloseAnim(&PlayBlock);
  175.     }
  176.  
  177.     freex(mem);
  178. }
  179.  
  180.  
  181. //------------------------------------------------------
  182. // PlaySample routines to link with Tony's ROTH sample stuff!
  183. //------------------------------------------------------
  184.  
  185. extern WORD PlaySample (_SOS_START_SAMPLE *mysample, void (far cdecl*callback)(WORD,WORD,WORD))
  186. {
  187.     mysample->lpCallback=(void cdecl (far*)(WORD,WORD,WORD))callback;
  188.    return (sosDIGIStartSample( DIGIDriverHandle, mysample));
  189. } /* PlaySample */
  190.  
  191.  
  192. extern WORD StopPlaySample (WORD handle)
  193. {
  194.    return (sosDIGIStopSample( DIGIDriverHandle, handle));
  195. }
  196.  
  197. extern WORD ChangeSampleVol (WORD handle,int vol)
  198. {
  199.    return (sosDIGISetSampleVolume( DIGIDriverHandle, handle,vol));
  200. }
  201.  
  202. extern WORD ChangeSamplePan (WORD handle,int pan)
  203. {
  204.    return (sosDIGISetPanLocation( DIGIDriverHandle, handle,pan));
  205. }
  206.